<div class="problemindexholder" problemindex="A">
 <div class="ttypography">
  <div class="problem-statement">
   <div class="header">
    <div class="title">
     A. Local Extrema
    </div>
    <div class="time-limit">
     <div class="property-title">
      time limit per test
     </div>
     1 second
    </div>
    <div class="memory-limit">
     <div class="property-title">
      memory limit per test
     </div>
     256 megabytes
    </div>
    <div class="input-file">
     <div class="property-title">
      input
     </div>
     standard input
    </div>
    <div class="output-file">
     <div class="property-title">
      output
     </div>
     standard output
    </div>
   </div>
   <div>
    <p>
     You are given an array
     <span class="tex-span">
      <i>
       a
      </i>
     </span>
     . Some element of this array
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
     </span>
     is a
     <span class="tex-font-style-it">
      local minimum
     </span>
     iff it is strictly less than both of its neighbours (that is,
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
      &lt;
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
       - 1
      </sub>
     </span>
     and
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
      &lt;
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
       + 1
      </sub>
     </span>
     ). Also the element can be called
     <span class="tex-font-style-it">
      local maximum
     </span>
     iff it is strictly greater than its neighbours (that is,
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
      &gt;
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
       - 1
      </sub>
     </span>
     and
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
      &gt;
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
       + 1
      </sub>
     </span>
     ). Since
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       1
      </sub>
     </span>
     and
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        n
       </i>
      </sub>
     </span>
     have only one neighbour each, they are neither local minima nor local maxima.
    </p>
    <p>
     An element is called a
     <span class="tex-font-style-it">
      local extremum
     </span>
     iff it is either local maximum or local minimum. Your task is to calculate the number of local extrema in the given array.
    </p>
   </div>
   <div class="input-specification">
    <div class="section-title">
     Input
    </div>
    <p>
     The first line contains one integer
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       n
      </i>
      ≤ 1000
     </span>
     ) — the number of elements in array
     <span class="tex-span">
      <i>
       a
      </i>
     </span>
     .
    </p>
    <p>
     The second line contains
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     integers
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       1
      </sub>
     </span>
     ,
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       2
      </sub>
     </span>
     , ...,
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        n
       </i>
      </sub>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
      ≤ 1000
     </span>
     ) — the elements of array
     <span class="tex-span">
      <i>
       a
      </i>
     </span>
     .
    </p>
   </div>
   <div class="output-specification">
    <div class="section-title">
     Output
    </div>
    <p>
     Print the number of local extrema in the given array.
    </p>
   </div>
   <div class="sample-tests">
    <div class="section-title">
     Examples
    </div>
    <div class="sample-test">
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>3<br/>1 2 3<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>0<br/></pre>
     </div>
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>4<br/>1 5 2 5<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>2<br/></pre>
     </div>
    </div>
   </div>
  </div>
  <p>
  </p>
 </div>
</div>
